package com.a3dweijing.wetouch2.Activity;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.a3dweijing.wetouch2.R;
import com.a3dweijing.wetouch2.datasave.Singleton;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyInviteActivity extends Activity
{
    
    @BindView(R.id.submit)
    Button submit;
    
    @BindView(R.id.code)
    TextView code;
    
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_invite);
        ButterKnife.bind(this);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        initView();
    }

    private void initView() {
        code.setText(Singleton.getInstance().getUser().getUser_id());
    }

    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
        finish();
        return super.onTouchEvent(event);
    }
    
    @OnClick(R.id.submit)
    public void onViewClicked() {
        //获取剪贴板管理器：  
        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
        // 创建普通字符型ClipData  
        ClipData mClipData = ClipData.newPlainText("Label", code.getText().toString());
        // 将ClipData内容放到系统剪贴板里。  
        cm.setPrimaryClip(mClipData);
        Toast.makeText(this, "复制成功", Toast.LENGTH_SHORT).show();
        finish();
    }
}
